Release 10.1A: OpenEdge Development:
ProDataSets
Using the MERGE-CHANGES method in the window procedure
You can replace most of the code that follows the
RUNupdateOrder.pstatement in theBtnSave CHOOSEtrigger with a single call toMERGE-CHANGES. In this case, you can apply all the changes back to the original ProDataSet with a single method call:
- Comment out or remove all the code in the
CHOOSE OF BtnSavetrigger starting at theCREATE QUERYstatement and ending with the end of theDO WHILE AVAILABLEblock.- Replace this with the
MERGE-CHANGESmethod on the ProDataSets to merge changes in the change ProDataSethDSChangesback into the origin ProDataSet whose handle ishDSOrder.- Remove the
ACCEPT-CHANGESmethod later in the trigger.MERGE-CHANGESdoes the work ofACCEPT-CHANGES, or in the case of a failed update,REJECT-CHANGES, as shown:
Design tip: Use the high-level methods like
MERGE-CHANGESreplaces all the code that builds a dynamic query on the change ProDataSet’s before-table, walks through it, finds the corresponding rows in the origin ProDataSet table, and copies final field values back into the origin ProDataSet. In addition, if there were any errors,MERGE-CHANGESwould reject those changes by restoring the origin ProDataSet rows back to their state before the update was attempted. UsingMERGE-CHANGES, you don’t need to worry about usingORIGIN-HANDLEandORIGIN-ROWID, following the chain ofRowIDsto theAFTER-ROWID, and so forth. The attributes are there for you to use only when you need to do something different from whatMERGE-CHANGESdoes for you in a single statement.SAVE-ROW-CHANGESandMERGE-CHANGESwhenever you can to take advantage of all the programming steps they take care of for you. However, don’t hesitate to code your own alternatives when the default behavior is not what you need in a particular situation.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |